import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import '@/utils/vant.js'
import '@/assets/reset.css';
import '@/assets/font/iconfont.js';
Vue.config.productionTip = false;
Vue.prototype.$bus = new Vue()
router.beforeEach((to,from,next)=>{
  // console.log(to);
  // console.log(from);
  if(localStorage.getItem('user')){
    next();
  }else {
    //没有登录，去跳转登录页
    if(to.path === '/login'){
      next();
    }
    else if(to.path === '/register'){
     next()
    }
    else{
      next({
        path:'/login'
      });
    }
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
